If you have contact with other languages, you should be exposed to the concept of a private variable. The so-called private is not protected, can not modify and access, only through the API you give access to the interface and modification. But
On the cnblogs to read some of the articles on JS, make a note:
First look at code 1:
function car () {
var wheel = 3;//Private variable
This.wheel = 4;//public variable
alert (wheel);
alert (This.wheel);
}
var car1 = new Car (); The result: 3
From the principle of design, if the member variable of a class is designed to be private, then we cannot get the value of this private variable outside the class. The usual practice is to provide the get and set methods for this private variable.
0
JS Object Private Variable public variable problem
5Little Brother Beginner JS Object-oriented Programming existing problem ask you prawns:
Person=function () {
Private variable definition
var name;
VAE age;
var
The principle of private instance variables is based on the scope. Private instance variables are implemented using the var keyword in JavaScript Functions and only valid within functions.
If you have been familiar with other languages, you should
Initially called method object_getinstancevariable (ID obj, const char *name, void**outvalue), use this method to actually get the value of the private variable to another class , but can only be used in non-ARC environments (configuration method:
Private variablesPrivate variablesAny variable defined in a function can be considered a private variable, because these variables cannot be accessed outside of the function.Private variables include arguments to functions, local variables, and
The name is a private variable, measured with isset () as ture, I know that I can use unset to delete the name in the object, could I do something else with name?
Reply to discussion (solution)
As long as you have permission, you can do any
Objective-CLearning notes acquisitionPrivate variableThe value is the content to be introduced in this article. It mainly describes how to obtainPrivate variableFor more information, see.
1. The following is a self-defined class with a private
You can use number as function/variable name, the numberic name can ' t is accessed from the parent scope, and can be accessed B Y ' this ' in private scope.var o= { attr1:' value of attr1 ', 1: ' Private attr, the index is 1 ', 3
Function newClass (){This. firstName = "Frank ";// Declares an instance field. new newClass (). firstName can be accessed only after the new object is created.// NewClass. firstName cannot be accessedVar lastName = "Zammetti ";// Declares a private
First look at the common function usage of javascript
Copy Code code as follows:
function sum (a,b) {
var C = 10;
function Add () {
C + +;
}
Add ();
Return a + B + C;
}
var d = sum (4,5);
Alert (d)//20
As
function A () { for (i=0;i<20;i++) { // No var i Here's I is global variable everyone can access } } function B () { for (i=0;i<3;i++) { //alert (i); I am also a global
Http://blog.chinaunix.net/uid-24148050-id-300576.html
Category: LINUX
First, Introduction A new feature on the 2.6 kernel is the PER-CPU variable. As the name suggests, there is a copy of this variable on each processor.The great advantage of
When you use some Javascript frameworks, you may see similar code
Copy Code code as follows:
var MyClass = new Class ({
Initialize:function (param, ...) {
This.param = param;
...
},
Func1:function (...) {
...
}
});
Create a new user object and accept an object with many attributes as parameters
The Code is as follows:
// Create a new user object and accept an object with many attributes as a parameterFunction User (properties){// Traverse all attributes
// Create a new user object and accept an object with many attributes as a parameterFunction User (properties){// Traverse all attributes of the object and ensure that its scope is correctFor (var I in properties ){(Function (which ){Var p = I;//
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.